package com.seguriapp.dao;

import static org.hibernate.criterion.Restrictions.eq;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.seguriapp.base.GenericDaoImpl;
import com.seguriapp.entities.Paperwork;
import com.seguriapp.entities.PaperworkAttribute;

/**
 * Data access object for {@link Paperwork} entities using Hibernate.
 * 
 * @author Tania Gonzales (taniadgv@gmail.com)
 */
@Repository
public class PaperworkDaoImpl extends GenericDaoImpl<Paperwork> implements PaperworkDao {

  public PaperworkDaoImpl() {
    super(Paperwork.class);
  }

  @SuppressWarnings("unchecked")
  public List<Paperwork> listActivePaperwork() {
    return getSession().createCriteria(Paperwork.class).add(eq("active", true)).list();
  }

  @SuppressWarnings("unchecked")
  public List<PaperworkAttribute> getPaperworkAttributeList(final Long paperworkId) {
    return getSession().createCriteria(PaperworkAttribute.class).add(eq("paperwork.id", paperworkId)).list();
  }

}
